package stack1;

import java.util.Stack;

public class Stack1 {
    //第二个数组是否为第一个数组的出栈
    public static void main(String[] args) {
        Stack<Integer> stack= new Stack<>();
        int[] arr1 = {1,2,3,4,5};
        int[] arr2 = {1,5,4,3,2};
        int j=0;
        for (int i = 0; i < arr1.length; i++) {
            stack.push(arr1[i]);
            while(j< arr2.length&&!stack.isEmpty()&&stack.peek()==arr2[j]){
                stack.pop();
                j++;
            }
        }
        System.out.println(stack.isEmpty());
    }
}
